﻿#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    file ="./config.ini";


}

Widget::~Widget()
{
    delete ui;
}


void Widget::readFile()
{
    char name[BUF_SIZE]={0};

    ini.read_profile_string("Activity","name", name, BUF_SIZE,"",file);
    qDebug()<<QString::fromLocal8Bit(name);
    ui->label->setText(QString::fromLocal8Bit(name));

    ini.read_profile_string("Activity","ip", name, BUF_SIZE,"",file);
    ui->label_2->setText(QString::fromLocal8Bit(name));
}

void Widget::saveFile()
{
    QString str = ui->lineEdit->text();
    ini.write_profile_string("Activity","name",(const char *)str.toLocal8Bit(),file);
}

void Widget::on_pushButton_clicked()
{
    readFile();
}

void Widget::on_pushButton_2_clicked()
{
    saveFile();
}
